import { WebSocketGateway, SubscribeMessage, MessageBody, ConnectedSocket } from '@nestjs/websockets';
import { Logger } from '@nestjs/common';
import { Socket } from 'socket.io';
@WebSocketGateway({ cors: true, maxHttpBufferSize: '1e8' })
export class SocketIoGateway {

  @SubscribeMessage('sendText')
  sendText(@MessageBody() data: any,
    @ConnectedSocket() client: Socket,) {
    console.log('sendText', data, client.broadcast);
    Logger.log('客户端发送的数据：' + JSON.stringify(data));
    client.broadcast.emit('sendText', data);
  }
  
}
